// const path = "http://localhost:8080/api"
const path = "http://150.158.193.51:8080/api"


function getUser() {
    axios({
        withCredentials: true,
        method: 'get',
        url: path + "/user/getUser",
    }).then(res => {
        if (res.data.resultCode === 200) {
            // alert(res.data.data)
        } else {
            alert(res.data.data)
            window.location.href = "../../pages/login.html"
        }
    })
}

window.onload=()=>{

    let logout = document.querySelector("#logout")
    logout.addEventListener("click", () => {
        axios({
            method: 'get',
            url: path + "/user/logout",
            withCredentials: true,
        }).then(res => {
            if (res.data.resultCode === 200) {
                alert(res.data.data)
                window.location.href = "../../pages/login.html"
            } else {
                alert(res.data.data)
                window.location.href = "../../pages/login.html"
            }
        })
    })

    let search_btn = document.querySelector("#search_btn")
    search_btn.onclick=()=>{
        let element = document.querySelector("#Yselect");
        let element1 = document.querySelector("#Mselect");
        alert(element.value)
        var x = element1.value
        if (element1.value<10)
            x = 0+element1.value
        alert(x)
    }

    getUser();
}
